<template>
	<view>
		<view class="address">
			<view class="address-con">
				<view class="con-left">
					<view class="con-left-img">
						<image :src="addressImg"></image>
					</view>
					<view class="con-left-text">
						<text>{{address}}</text>
					</view>
				</view>
				<view class="con-right" @click="chooseAddress">
					<view class="con-right-img">
						<image :src="changeImg"></image>
					</view>
					<view class="con-right-text">
						<text>更换地址</text>
					</view>
				</view>
			</view>
		</view>
		<view class="address-zw"></view>
	</view>
</template>

<script>
	import {
		getMapLocation
	} from '@/api/uniapp/uni.js'

	export default {
		props: ['address'],
		data() {
			return {
				addressImg: require('@/static/img/main/home/address/01.svg'),
				changeImg: require('@/static/img/main/home/address/02.svg')
			}
		},
		methods: {
			//修改当前定位
			chooseAddress() {
				//判断用户是否登录
				// this.$isLoginByVisitor()
				// if(uni.getStorageSync('isVisitorLogin')){
				// 	return
				// }
				
				getMapLocation().then(res => {
					//console.log(res)
					this.$emit('changeAddress', res)
					//this.actUpdateDwAddressData(res)
				}).catch(err => {
					console.log(err)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.address-zw {
		height: calc(100rpx + var(--status-bar-height));
	}

	.address {
		padding-top: var(--status-bar-height);
		position: fixed;
		z-index: 9;
		top: 0;
		left: 0;
		background-color: #23D754;
		width: 100%;

		.address-con {
			height: 100rpx;
			width: 100%;
			display: flex;

			.con-left {
				width: 80%;
				display: flex;

				.con-left-img {
					image {
						margin: 20rpx 10rpx;
						width: 60rpx;
						height: 60rpx;
					}
				}

				.con-left-text {
					line-height: 100rpx;
					font-size: 32rpx;
					color: #fff;

					text {
						display: -webkit-box;
						/** 对象作为伸缩盒子模型显示 **/
						overflow: hidden;
						word-break: break-all;
						/* break-all(允许在单词内换行。) https://www.w3school.com.cn/cssref/pr_word-break.asp*/
						text-overflow: ellipsis;
						/* 超出部分省略号 */
						-webkit-box-orient: vertical;
						/** 设置或检索伸缩盒对象的子元素的排列方式 **/
						-webkit-line-clamp: 1;
						/** 显示的行数 **/
					}
				}
			}

			.con-right {
				width: 20%;

				.con-right-img {
					text-align: center;
					height: 60rpx;

					image {
						margin-top: 20rpx;
						width: 40rpx;
						height: 40rpx;
					}

				}

				.con-right-text {
					text-align: center;
					height: 40rpx;
					line-height: 20rpx;

					text {
						font-size: 24rpx;
						color: #fff;
					}
				}
			}
		}
	}
</style>